// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "AbilitySystem/Abilities/LyraGameplayAbility.h"
#include "Interaction/InteractionOption.h"

#include "LyraGameplayAbility_Interact.generated.h"

class UIndicatorDescriptor;
class UObject;
class UUserWidget;
struct FFrame;
struct FGameplayAbilityActorInfo;
struct FGameplayEventData;

/**
 * ULyraGameplayAbility_Interact
 *
 * 用于角色交互的Gameplay Ability
 */
UCLASS(Abstract)
class ULyraGameplayAbility_Interact : public ULyraGameplayAbility
{
	GENERATED_BODY()

public:

	ULyraGameplayAbility_Interact(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());

	/**
	 * 激活Ability
	 * @param Handle Ability的句柄
	 * @param ActorInfo 持有此Ability的Actor信息
	 * @param ActivationInfo 此次激活的信息
	 * @param TriggerEventData 触发此Ability的事件数据
	 */
	virtual void ActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, const FGameplayEventData* TriggerEventData) override;

	/**
	 * 更新可用的交互选项
	 * @param InteractiveOptions 新的交互选项数组
	 */
	UFUNCTION(BlueprintCallable)
	void UpdateInteractions(const TArray<FInteractionOption>& InteractiveOptions);

	/**
	 * 触发交互（通常响应玩家输入）
	 */
	UFUNCTION(BlueprintCallable)
	void TriggerInteraction();

protected:
	UPROPERTY(BlueprintReadWrite)
	TArray<FInteractionOption> CurrentOptions; // 当前可用的交互选项

	UPROPERTY()
	TArray<TObjectPtr<UIndicatorDescriptor>> Indicators; // 当前显示的指示器描述符数组

protected:

	UPROPERTY(EditDefaultsOnly)
	float InteractionScanRate = 0.1f; // 交互扫描的频率（秒）

	UPROPERTY(EditDefaultsOnly)
	float InteractionScanRange = 500; // 交互扫描的范围

	UPROPERTY(EditDefaultsOnly)
	TSoftClassPtr<UUserWidget> DefaultInteractionWidgetClass; // 默认的交互界面控件类
};